home *** CD-ROM | disk | FTP | other *** search
/ Inter.Net 55-1 / Inter.Net 55-1.iso / CBuilder / Setup / BCB / data.z / string.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-02-09  |  15.8 KB  |  410 lines

  1. /*  string.h
  2.  
  3.     Definitions for string functions.
  4.  
  5. */
  6.  
  7. /*
  8.  *      C/C++ Run Time Library - Version 9.0
  9.  *
  10.  *      Copyright (c) 1987, 1998 by Borland International
  11.  *      All Rights Reserved.
  12.  *
  13.  */
  14. /* $Revision:   9.5  $ */
  15.  
  16. #ifndef __STRING_H
  17. #define __STRING_H
  18. #define _INC_STRING  /* MSC Guard name */
  19.  
  20. #ifndef ___STDDEF_H
  21. #include <_stddef.h>
  22. #endif
  23.  
  24. #if !defined(__STDC__) && defined(__USELOCALES__)
  25. #if !defined(__LOCALE_H)
  26. #include <locale.h>
  27. #endif
  28. #endif  /* !__STDC__ && __USELOCALES__ */
  29.  
  30. #if !defined(RC_INVOKED)
  31.  
  32. #ifndef __MEM_H
  33. #include <mem.h>  /* All mem... functions have now been moved to MEM.H */
  34. #endif
  35.  
  36. #if defined(__STDC__)
  37. #pragma warn -nak
  38. #endif
  39.  
  40. #endif  /* !RC_INVOKED */
  41.  
  42. #ifdef __cplusplus
  43. extern "C" {
  44. #endif
  45.  
  46. #ifdef __cplusplus
  47. namespace std {
  48. #endif /* __cplusplus */
  49.  
  50. #define wcscmpi(s1,s2)      _wcsicmp(s1,s2)
  51. #define _wcscmpi(s1,s2)     _wcsicmp(s1,s2)
  52. #define wcsncmpi(s1,s2,n)   _wcsnicmp(s1,s2,n)
  53. #define _wcsncmpi(s1,s2,n)  _wcsnicmp(s1,s2,n)
  54.  
  55. _SIZE_T          _RTLENTRY  _EXPFUNC wcslen(const wchar_t *__s);
  56. wchar_t *       _RTLENTRY  _EXPFUNC wcscpy(wchar_t *__dst, const wchar_t *__src);
  57. wchar_t *       _RTLENTRY  _EXPFUNC wcscat(wchar_t *__dest, const wchar_t *__src);
  58. wchar_t *       _RTLENTRY  _EXPFUNC wcschr(const wchar_t *__s, int __c);
  59. int             _RTLENTRY  _EXPFUNC wcscmp(const wchar_t *__s1, const wchar_t *__s2);
  60. int             _RTLENTRY  _EXPFUNC wcscoll(const wchar_t * __s1, const wchar_t * __s2);
  61. _SIZE_T          _RTLENTRY  _EXPFUNC wcscspn(const wchar_t *__s1, const wchar_t *__s2);
  62. wchar_t *       _RTLENTRY  _EXPFUNC _wcsdup(const wchar_t *__s);
  63. int             _RTLENTRY  _EXPFUNC wcsncmp(const wchar_t *__s1, const wchar_t *__s2, _SIZE_T __maxlen);
  64. wchar_t *       _RTLENTRY  _EXPFUNC wcsncpy(wchar_t *__dest, const wchar_t *__src, _SIZE_T __maxlen);
  65. wchar_t *       _RTLENTRY  _EXPFUNC _wcsnset(wchar_t *__s, wchar_t __ch, _SIZE_T __n);
  66. wchar_t *       _RTLENTRY  _EXPFUNC wcspbrk(const wchar_t *__s1, const wchar_t *__s2);
  67. wchar_t *       _RTLENTRY  _EXPFUNC wcsrchr(const wchar_t *__s, wchar_t __c);
  68. wchar_t *       _RTLENTRY  _EXPFUNC _wcsrev(wchar_t *__s);
  69. wchar_t *       _RTLENTRY  _EXPFUNC _wcsset(wchar_t*__s, wchar_t __ch);
  70. _SIZE_T          _RTLENTRY  _EXPFUNC wcsspn(const wchar_t *__s1, const wchar_t *__s2);
  71. wchar_t *       _RTLENTRY  _EXPFUNC wcsstr(const wchar_t *__s1, const wchar_t *__s2);
  72. wchar_t *       _RTLENTRY  _EXPFUNC wcstok(wchar_t *__s1, const wchar_t *__s2);
  73. wchar_t *       _RTLENTRY  _EXPFUNC wcsncat(wchar_t *__dest, const wchar_t *__src, _SIZE_T __maxlen);
  74. wchar_t *       _RTLENTRY  _EXPFUNC wcspcpy(wchar_t *__dest, const wchar_t *__src);
  75. wchar_t *       _RTLENTRY  _EXPFUNC _wcspcpy(wchar_t *__dest, const wchar_t *__src);
  76. int             _RTLENTRY  _EXPFUNC _wcsicmp(const wchar_t *__s1, const wchar_t *__s2);
  77. int             _RTLENTRY  _EXPFUNC _wcsnicmp(const wchar_t *__s1, const wchar_t *__s2, _SIZE_T __maxlen);
  78. wchar_t *       _RTLENTRYF _EXPFUNC _wcslwr(wchar_t *__s);
  79. wchar_t *       _RTLENTRYF _EXPFUNC _wcsupr(wchar_t *__s);
  80. wchar_t *       _RTLENTRYF _EXPFUNC _lwcslwr(wchar_t *__s);
  81. wchar_t *       _RTLENTRYF _EXPFUNC _lwcsupr(wchar_t *__s);
  82.  
  83. char _FAR * _RTLENTRYF _EXPFUNC strcat(char _FAR *__dest, const char _FAR *__src);
  84. int         _RTLENTRYF _EXPFUNC strcmp(const char _FAR *__s1, const char _FAR *__s2);
  85. char _FAR * _RTLENTRYF _EXPFUNC strcpy(char _FAR *__dest, const char _FAR *__src);
  86. _SIZE_T      _RTLENTRY  _EXPFUNC strcspn(const char _FAR *__s1, const char _FAR *__s2);
  87. char _FAR * _RTLENTRY  _EXPFUNC strerror(int __errnum);
  88. _SIZE_T      _RTLENTRYF _EXPFUNC strlen(const char _FAR *__s);
  89. char _FAR * _RTLENTRYF _EXPFUNC strncat(char _FAR *__dest, const char _FAR *__src,
  90.                                         _SIZE_T __maxlen);
  91. int         _RTLENTRYF _EXPFUNC strncmp(const char _FAR *__s1, const char _FAR *__s2,
  92.                                         _SIZE_T __maxlen);
  93. char _FAR * _RTLENTRYF _EXPFUNC strncpy(char _FAR *__dest, const char _FAR *__src,
  94.                                         _SIZE_T __maxlen);
  95. _SIZE_T      _RTLENTRY  _EXPFUNC strspn(const char _FAR *__s1, const char _FAR *__s2);
  96. char _FAR * _RTLENTRYF _EXPFUNC strtok(char _FAR *__s1, const char _FAR *__s2);
  97. char _FAR * _RTLENTRY  _EXPFUNC _strerror(const char _FAR *__s);
  98.  
  99.  
  100. #if !defined(__STDC__)
  101. /* compatibility with other compilers */
  102. #define strcmpi(s1,s2)      stricmp(s1,s2)
  103. #define strncmpi(s1,s2,n)   strnicmp(s1,s2,n)
  104.  
  105. char _FAR * _RTLENTRYF _EXPFUNC   _lstrlwr(char _FAR *__s);
  106. char _FAR * _RTLENTRYF _EXPFUNC   _lstrupr(char _FAR *__s);
  107. char _FAR * _RTLENTRYF _EXPFUNC32 stpcpy(char _FAR *__dest, const char _FAR *__src);
  108. char _FAR * _RTLENTRY  _EXPFUNC32 _stpcpy(char _FAR *__dest, const char _FAR *__src);
  109. char _FAR * _RTLENTRY  _EXPFUNC   strdup(const char _FAR *__s);
  110. int         _RTLENTRYF _EXPFUNC   stricmp(const char _FAR *__s1, const char _FAR *__s2);
  111. char _FAR * _RTLENTRYF _EXPFUNC   strlwr(char _FAR *__s);
  112. int         _RTLENTRYF _EXPFUNC   strnicmp(const char _FAR *__s1, const char _FAR *__s2,
  113.                                            _SIZE_T __maxlen);
  114. char _FAR * _RTLENTRY  _EXPFUNC   strnset(char _FAR *__s, int __ch, _SIZE_T __n);
  115. char _FAR * _RTLENTRY  _EXPFUNC   strrev(char _FAR *__s);
  116. char _FAR * _RTLENTRY  _EXPFUNC   strset(char _FAR *__s, int __ch);
  117. char _FAR * _RTLENTRYF _EXPFUNC   strupr(char _FAR *__s);
  118. #endif  /* !__STDC__ */
  119.  
  120.  
  121. #if defined(__cplusplus)
  122. extern "C++"
  123. {
  124.           char _FAR * _RTLENTRYF _EXPFUNC   strchr(char _FAR * __s, int __c);
  125.     const char _FAR * _RTLENTRYF _EXPFUNC   strchr(const char _FAR * __s, int __c);
  126.           char _FAR * _RTLENTRYF _EXPFUNC   strrchr(char _FAR *__s, int __c);
  127.     const char _FAR * _RTLENTRYF _EXPFUNC   strrchr(const char _FAR *__s, int __c);
  128.           char _FAR * _RTLENTRYF _EXPFUNC   strpbrk(char _FAR *__s1, const char _FAR *__s2);
  129.     const char _FAR * _RTLENTRYF _EXPFUNC   strpbrk(const char _FAR *__s1, const char _FAR *__s2);
  130.           char _FAR * _RTLENTRY  _EXPFUNC   strstr(char _FAR *__s1, const char _FAR *__s2);
  131.     const char _FAR * _RTLENTRY  _EXPFUNC   strstr(const char _FAR *__s1, const char _FAR *__s2);
  132. }
  133. #else
  134.           char _FAR * _RTLENTRYF _EXPFUNC   strchr(const char _FAR * __s, int __c);
  135.           char _FAR * _RTLENTRYF _EXPFUNC   strrchr(const char _FAR *__s, int __c);
  136.           char _FAR * _RTLENTRYF _EXPFUNC   strpbrk(const char _FAR *__s1, const char _FAR *__s2);
  137.           char _FAR * _RTLENTRY  _EXPFUNC   strstr(const char _FAR *__s1, const char _FAR *__s2);
  138. #endif
  139.  
  140.  
  141. /* Intrinsic functions */
  142.  
  143. /* Intrinsics must be prototyped outside of any namespace */
  144. #ifdef __cplusplus
  145. } // std
  146. #endif /* __cplusplus */
  147.  
  148. char _FAR * _RTLENTRY             __stpcpy__(char _FAR *__dest, const char _FAR *__src);
  149. char _FAR * _RTLENTRYF _EXPFUNC16 __strcat__(char _FAR *__dest, const char _FAR *__src);
  150. char _FAR * _RTLENTRY  _EXPFUNC16 __strchr__(const char _FAR *__s, int __c);
  151. int         _RTLENTRYF _EXPFUNC16 __strcmp__(const char _FAR *__s1, const char _FAR *__s2);
  152. char _FAR * _RTLENTRYF _EXPFUNC16 __strcpy__(char _FAR *__dest, const char _FAR *__src);
  153. _SIZE_T     _RTLENTRYF _EXPFUNC16 __strlen__(const char _FAR *__s);
  154. char _FAR * _RTLENTRY  _EXPFUNC16 __strncat__(char _FAR *__dest, const char _FAR *__src,
  155.                                               _SIZE_T __maxlen);
  156. int         _RTLENTRY  _EXPFUNC16 __strncmp__(const char _FAR *__s1, const char _FAR *__s2,
  157.                                               _SIZE_T __maxlen);
  158. char _FAR * _RTLENTRYF _EXPFUNC16 __strncpy__(char _FAR *__dest, const char _FAR *__src,
  159.                                               _SIZE_T __maxlen);
  160. char _FAR * _RTLENTRY  _EXPFUNC16 __strnset__(char _FAR *__s, int __ch, _SIZE_T __n);
  161. char _FAR * _RTLENTRYF _EXPFUNC16 __strrchr__(const char _FAR *__s, int __c);
  162. char _FAR * _RTLENTRY  _EXPFUNC16 __strset__(char _FAR *__s, int __ch);
  163.  
  164. /* Now that the intrinsics are finished, turn the namespace back on */
  165. #ifdef __cplusplus
  166. namespace std {
  167. #endif /* __cplusplus */
  168.  
  169.  
  170. #if defined(__MSC) && !defined(__MFC_COMPAT__)
  171. #define _stricmp(s1,s2) stricmp(s1,s2)
  172. #define _strdup(s1)     strdup(s1)
  173. #define _strupr(s1)     strupr(s1)
  174. #define _strlwr(s1)     strlwr(s1)
  175. #define _strrev(s1)     strrev(s1)
  176. #endif  /* __MSC */
  177.  
  178. #if defined(__MFC_COMPAT__)
  179. inline char _FAR * _RTLENTRY  _strrev(char _FAR *__s) { return strrev(__s); }
  180.  
  181. inline char _FAR * _RTLENTRY  _strset(char _FAR *__s, int __ch)
  182.                               { return strset(__s, __ch); }
  183. inline char _FAR * _RTLENTRY  _strnset(char _FAR *__s, int __ch, _SIZE_T __n)
  184.                               { return strnset(__s, __ch, __n); }
  185. inline char _FAR * _RTLENTRYF _strupr(char _FAR *__s) { return strupr(__s); }
  186.  
  187. inline char _FAR * _RTLENTRYF _strlwr(char _FAR *__s) { return strlwr(__s); }
  188.  
  189. inline char _FAR * _RTLENTRY  _strdup(const char _FAR *__s)
  190.                               { return strdup(__s); }
  191. inline int         _RTLENTRYF _strcmpi(const char _FAR *__s1, const char _FAR *__s2)
  192.                               { return stricmp (__s1, __s2); }
  193. inline int         _RTLENTRYF _stricmp(const char _FAR *__s1, const char _FAR *__s2)
  194.                               { return stricmp (__s1, __s2); }
  195. inline int         _RTLENTRYF _strcmp(const char _FAR *__s1, const char _FAR *__s2)
  196.                               { return strcmp (__s1, __s2); }
  197. inline int         _RTLENTRYF _strnicmp(const char _FAR *__s1, const char _FAR *__s2, _SIZE_T __maxlen)
  198.                               { return strnicmp (__s1, __s2, __maxlen); }
  199. #endif
  200.  
  201. int    _RTLENTRY  _EXPFUNC _lstrcoll(const char * __s1, const char * __s2);
  202. int    _RTLENTRY  _EXPFUNC _lstricoll(const char * __s1, const char * __s2);
  203. int    _RTLENTRY  _EXPFUNC _lstrncoll(const char * __s1, const char * __s2, const int __len);
  204. int    _RTLENTRY  _EXPFUNC _lstrnicoll(const char * __s1, const char * __s2, int __len);
  205. _SIZE_T _RTLENTRY  _EXPFUNC _lstrxfrm(char * __s1, const char * __s2,_SIZE_T __n );
  206. int    _RTLENTRY  _EXPFUNC strcoll(const char * __s1, const char * __s2);
  207. int    _RTLENTRY  _EXPFUNC _stricoll(const char * __s1, const char * __s2);
  208. int    _RTLENTRY  _EXPFUNC _strncoll(const char * __s1, const char * __s2, _SIZE_T __n);
  209. int    _RTLENTRY  _EXPFUNC _strnicoll(const char * __s1, const char * __s2, int __len);
  210. _SIZE_T _RTLENTRY  _EXPFUNC strxfrm(char * __s1, const char * __s2,_SIZE_T __n );
  211.  
  212. int    _RTLENTRY  _EXPFUNC _lwcscoll(const wchar_t * __s1, const wchar_t * __s2);
  213. int    _RTLENTRY  _EXPFUNC _lwcsicoll(const wchar_t * __s1, const wchar_t * __s2);
  214. int    _RTLENTRY  _EXPFUNC _lwcsncoll(const wchar_t * __s1, const wchar_t * __s2, const int __len);
  215. int    _RTLENTRY  _EXPFUNC _lwcsnicoll(const wchar_t * __s1, const wchar_t * __s2, int __len);
  216. _SIZE_T _RTLENTRY  _EXPFUNC _lwcsxfrm(wchar_t * __s1, const wchar_t * __s2,_SIZE_T __n );
  217. int    _RTLENTRY  _EXPFUNC wcscoll(const wchar_t * __s1, const wchar_t * __s2);
  218. int    _RTLENTRY  _EXPFUNC _wcsicoll(const wchar_t * __s1, const wchar_t * __s2);
  219. int    _RTLENTRY  _EXPFUNC _wcsncoll(const wchar_t * __s1, const wchar_t * __s2, _SIZE_T __n);
  220. int    _RTLENTRY  _EXPFUNC _wcsnicoll(const wchar_t * __s1, const wchar_t * __s2, int __len);
  221. _SIZE_T _RTLENTRY  _EXPFUNC wcsxfrm(wchar_t * __s1, const wchar_t * __s2, _SIZE_T __n );
  222.  
  223.  
  224. #if !defined(__STDC__) /* NON_ANSI  */
  225. #define _fstrcat   strcat
  226. #define _fstrchr   strchr
  227. #define _fstrcmp   strcmp
  228. #define _fstrcpy   strcpy
  229. #define _fstrcspn  strcspn
  230. #define _fstrdup   strdup
  231. #define _fstricmp  stricmp
  232. #define _fstrlen   strlen
  233. #define _fstrlwr   strlwr
  234. #define _fstrncat  strncat
  235. #define _fstrncmp  strncmp
  236. #define _fstrncpy  strncpy
  237. #define _fstrnicmp strnicmp
  238. #define _fstrnset  strnset
  239. #define _fstrpbrk  strpbrk
  240. #define _fstrrchr  strrchr
  241. #define _fstrrev   strrev
  242. #define _fstrset   strset
  243. #define _fstrspn   strspn
  244. #define _fstrstr   strstr
  245. #define _fstrtok   strtok
  246. #define _fstrupr   strupr
  247. #endif /* __STDC__  */
  248.  
  249. #if defined(__USELOCALES__)
  250. #define  strupr     _lstrupr
  251. #define  strlwr     _lstrlwr
  252. #define  strcoll    _lstrcoll
  253. #define  stricoll   _lstricoll
  254. #define  strncoll   _lstrncoll
  255. #define  strnicoll  _lstrnicoll
  256. #define  strxfrm    _lstrxfrm
  257. #endif  /* __USELOCALES__ */
  258.  
  259. #if !defined(RC_INVOKED)
  260.  
  261. #if defined(__STDC__)
  262. #pragma warn .nak
  263. #endif
  264.  
  265. #endif  /* !RC_INVOKED */
  266.  
  267. #ifdef __cplusplus
  268. } // std
  269. #endif /* __cplusplus */
  270.  
  271. #ifdef __cplusplus
  272. }
  273. #endif
  274.  
  275. #endif  /* __STRING_H */
  276.  
  277. #if defined(__cplusplus) && !defined(__USING_CNAME__) && !defined(__STRING_H_USING_LIST)
  278. #define __STRING_H_USING_LIST
  279. #if !defined(__STDC__)
  280.      using std::_lstrlwr;
  281.      using std::_lstrupr;
  282.      using std::_stpcpy;
  283.      using std::strdup;
  284.      using std::stricmp;
  285.      using std::strlwr;
  286.      using std::strnicmp;
  287.      using std::strrev;
  288.      using std::strupr;
  289. #endif
  290. #if defined(__MFC_COMPAT__)
  291.  
  292.      using std::_strrev;
  293.      using std::_strset;
  294.      using std::_strnset;
  295.      using std::_strupr;
  296.      using std::_strdup;
  297.      using std::_strlwr;
  298.      using std::_strcmpi;
  299.      using std::_stricmp;
  300.      using std::_strcmp;
  301.      using std::_strnicmp;
  302. #endif
  303.      using std::_lstrcoll;
  304.      using std::_lstricoll;
  305.      using std::_lstrncoll;
  306.      using std::_lstrnicoll;
  307.      using std::_lstrxfrm;
  308.      using std::_lwcscoll;
  309.      using std::_lwcsicoll;
  310.      using std::_lwcslwr;
  311.      using std::_lwcsncoll;
  312.      using std::_lwcsnicoll;
  313.      using std::_lwcsupr;
  314.      using std::_lwcsxfrm;
  315.      using std::_strerror;
  316.      using std::_stricoll;
  317.      using std::_strncoll;
  318.      using std::_strnicoll;
  319.      using std::_wcsdup;
  320.      using std::_wcsicmp;
  321.      using std::_wcsicoll;
  322.      using std::_wcslwr;
  323.      using std::_wcsncoll;
  324.      using std::_wcsnicmp;
  325.      using std::_wcsnicoll;
  326.      using std::_wcsnset;
  327.      using std::_wcspcpy;
  328.      using std::_wcsrev;
  329.      using std::_wcsset;
  330.      using std::_wcsupr;
  331.  
  332. /*
  333.    Handle intrinsics specially.  If intrinsics are on, the compiler creates
  334.    a macro of the normal function mapping to the __ intrinsic version, ie:
  335.      #define strcpy __strcpy__
  336.    Thus, we can test the normal name as a macro to see if it's defined, and
  337.    only preform a using statement if it's not an intrinsic
  338. */
  339.  
  340. #if !defined(__STDC__)
  341. #    ifndef strnset
  342.     using std::strnset;
  343. #    endif // ifndef strnset
  344. #    ifndef stpcpy
  345.     using std::stpcpy;
  346. #    endif // ifndef stpcpy
  347. #    ifndef strset
  348.     using std::strset;
  349. #    endif // ifndef strset
  350. #endif // __STDC__
  351.  
  352. #    ifndef strcat
  353.     using std::strcat;
  354. #    endif // ifndef strcat
  355. #    ifndef strchr
  356.     using std::strchr;
  357. #    endif // ifndef strchr
  358. #    ifndef strcmp
  359.     using std::strcmp;
  360. #    endif // ifndef strcmp
  361. #    ifndef strcpy
  362.     using std::strcpy;
  363. #    endif // ifndef strcpy
  364. #    ifndef strlen
  365.     using std::strlen;
  366. #    endif // ifndef strlen
  367. #    ifndef strncat
  368.     using std::strncat;
  369. #    endif // ifndef strncat
  370. #    ifndef strncmp
  371.     using std::strncmp;
  372. #    endif // ifndef strncmp
  373. #    ifndef strncpy
  374.     using std::strncpy;
  375. #    endif // ifndef strncpy
  376. #    ifndef strrchr
  377.     using std::strrchr;
  378. #    endif // ifndef strrchr
  379.  
  380.      using std::strcspn;
  381.      using std::strerror;
  382.      using std::strpbrk;
  383.      using std::strspn;
  384.      using std::strstr;
  385.      using std::strtok;
  386.      using std::strxfrm;
  387.      using std::strcoll;
  388.  
  389.      using std::wcscat;
  390.      using std::wcschr;
  391.      using std::wcscmp;
  392.      using std::wcscoll;
  393.      using std::wcscpy;
  394.      using std::wcscspn;
  395.      using std::wcslen;
  396.      using std::wcsncat;
  397.      using std::wcsncmp;
  398.      using std::wcsncpy;
  399.      using std::wcspbrk;
  400.      using std::wcspcpy;
  401.      using std::wcsrchr;
  402.      using std::wcsspn;
  403.      using std::wcsstr;
  404.      using std::wcstok;
  405.      using std::wcsxfrm;
  406. #endif /* __USING_CNAME__ */
  407.  
  408. #if defined(__USING_STD_NAMES__) && !defined(__STD_STRING)
  409. #  include <string.stl>
  410. #endif  /* __USING_STD_NAMES__ */